#include<iostream>
#include <malloc.h>
#include <xmmintrin.h>

typedef double real;

int main()
{
  size_t N=86;
  real *a = (real*) _mm_malloc(N*sizeof(real), 16);
  real *b = (real*) _mm_malloc(N*sizeof(real), 16); 
  for(size_t i=0;i<N;++i){
    a[i]=i;
    b[i]=i+1;
  }
  /*for(size_t i=0;i<N;i+=2)
  {
    //__m128d bi=_mm_load_pd(&a[i]);
    __m128d toAdd=_mm_set_pd(i+1.0,i+0.0);
    _mm_store_pd(&a[i],toAdd);
    __m128d toAddb=_mm_set_pd(i+2.0,i+1.0);
    _mm_store_pd(&b[i],toAddb);
  }*/
  //It does not start in the first position :s is like the first entry is ignored thats why the +1 is in the first parameter
  for(size_t i=0;i<N;i+=2)
  {
    __m128d ai=_mm_load_pd(&a[i]);
    __m128d bi=_mm_load_pd(&b[i]);
    __m128d store = _mm_add_pd(ai,bi);
    _mm_store_pd(&a[i],store);
  }
  for(size_t i=0;i<N;++i)
    std::cout<<i<<"  "<<b[i]<<"  "<<a[i]<<"\n";
    _mm_free(a);
    _mm_free(b);
  return 0;
}
